home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / rexx / recordconversation.avm < prev    next >
Text File  |  1994-06-24  |  11KB  |  428 lines

  1. /* TITLE: avm:rexx/recordconversation.avm */
  2. /* we want results! Otherwise, we wouldn't get anything from RESULT */
  3. options results
  4.  
  5. /* Need to make sure that stdtail.avm is also included */
  6. signal on halt
  7. signal on novalue
  8. signal on syntax
  9. signal on break_c
  10.  
  11. /* needed for some of the functions we use */
  12. call addlib("rexxsupport.library", 0, -30, 0)
  13.  
  14. /* a higher than normal priority since calls are important to us :) */
  15. call pragma('priority', 1)
  16.  
  17. /* ensure that commands are directed to the correct server */
  18. parse arg servername .
  19. address value servername
  20.  
  21.  
  22. /* Initialize log */
  23.  
  24. handle = makeUniqueFile()
  25. call initLogEntry()
  26. call time('r')
  27.  
  28. 'recordvoice' '500' '-1' '-1' voiceFile('manual', handle)
  29. action = rc
  30. select
  31.   when action = 0 then nop
  32.   when action = 1 then nop
  33.   when action = 2 then nop
  34.   when action = 3 then nop
  35.   when action = 4 then nop
  36.   when action = 5 then nop
  37.   when action = 8 then nop
  38.   when action = 10 then nop
  39.   when action = 12 then nop
  40.   when action = 14 then nop
  41.   when action = 16 then nop
  42.   otherwise signal arexxerror
  43. end
  44.  
  45. /* Save log entry */
  46.  
  47. log.filename = handle
  48. log.length = trunc(time('e'))
  49. log.comment = 'Recorded Manually'
  50. log.type = 'voice'
  51. call saveLogEntry('manual', handle)
  52.  
  53. /* TITLE: avm:rexx/simplestdtail.avm */
  54. /* This is the standard tail */
  55. exit
  56.  
  57. exit
  58.  
  59. mailboxDir: procedure
  60.     parse arg mailbox
  61.  
  62.     return 'avm:' || mailbox || '/'
  63.  
  64. logFile: procedure
  65.     parse arg mailbox, magiccookie
  66.  
  67.     return 'avm:' || mailbox || '/logs/' || magiccookie
  68.  
  69. voiceFile: procedure
  70.     parse arg mailbox, magiccookie
  71.  
  72.         if (verify(magiccookie, '/:', 'M') = 0) then
  73.           return 'avm:' || mailbox || '/voices/' || magiccookie
  74.         else
  75.           return magiccookie
  76.  
  77. makeUniqueFile: procedure
  78.     if arg() ~= 0 then do
  79.         rc = "makeUniqueFile: bad args"
  80.         signal error
  81.     end
  82.     return address() || '.' || date('i') || '.' || time('s') || '.' || random(1, 999, time('s'))
  83.  
  84. convertToDate: procedure
  85.     if arg() ~= 1 then do
  86.         rc = "convertToDate: bad args"
  87.         signal error
  88.     end
  89.     parse arg timeInC
  90.  
  91.     actualTime = (timeInC - (2922)*86400) // (86400)
  92.     actualDate = (timeInC - actualTime - 2922*86400) % 86400
  93.  
  94.     return actualDate /* returning it in 'internal' format */
  95.  
  96. convertToTime: procedure
  97.     if arg() ~= 1 then do
  98.         rc = "convertToTime: bad args"
  99.         signal error
  100.     end
  101.     parse arg timeInC
  102.     
  103.     actualTime = (timeInC - (2922)*86400) // (86400)
  104.  
  105.     return actualTime
  106.  
  107. cTime: procedure
  108.     /* 2922 = 8*365 + 2 */
  109.     /* 86400 = 24*60*60 */
  110.     return (date('i')+2922)*86400 + time('s')
  111.  
  112. /* this returns a handle that you must use after initializing log. */
  113. initLogEntry: procedure expose log.
  114.     if arg() ~= 0 then do
  115.         rc = "initLogEntry: bad args"
  116.         signal error
  117.     end
  118.     
  119.     drop log.
  120.         log. = ''
  121.  
  122.         acidname = getclip(address() || 'CIDNAME')
  123.         acidnumber = getclip(address() || 'CIDNUMBER')
  124.  
  125.     /* 2922 = 8*365 + 2 */
  126.     /* 86400 = 24*60*60 */
  127.     log.time = (date('i')+2922)*86400 + time('s')
  128.     log.cidname = acidname
  129.     log.cidnumber = acidnumber
  130.  
  131.     return
  132.  
  133. loadLogEntry: procedure expose log.
  134.     if arg() ~= 2 then do
  135.         rc = "loadLogEntry: bad args"
  136.         signal error
  137.     end
  138.     parse arg mailbox, handle
  139.  
  140.         drop log.
  141.         log. = ''
  142.  
  143.     if ~exists(mailboxDir(mailbox)) then do
  144.         call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
  145.         return
  146.     end
  147.  
  148.     opened = open(handle, logFile(mailbox, handle), 'r')
  149.         if opened then do
  150.         call showDebugger('Loading entry' logFile(mailbox, handle))
  151.         do while ~eof(handle)
  152.             line = readln(handle)
  153.             parse upper var line variable '=' value
  154.             log.variable = value
  155.         end
  156.         call close(handle)
  157.     end; else call showDebugger('Could not load' logFile(mailbox, handle))
  158.     return
  159.  
  160. /* pass a handle here */
  161. saveLogEntry: procedure expose log.
  162.     if arg() ~= 2 then do
  163.         rc = "saveLogEntry: bad args"
  164.         signal error
  165.     end
  166.     parse arg mailbox, handle
  167.  
  168.     if ~exists(mailboxDir(mailbox)) then do
  169.         call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
  170.         return
  171.     end
  172.  
  173.     opened = open(handle, logFile(mailbox, handle), 'w')
  174.  
  175.     if opened then do
  176.         call showDebugger('Saving entry' logFile(mailbox, handle))
  177.         call writeln(handle, 'TYPE=' || log.type)
  178.         call writeln(handle, 'TIME=' || log.time)
  179.         call writeln(handle, 'LENGTH=' || log.length)
  180.  
  181.         call writeln(handle, 'ORIGMAILBOX=' || log.origmailbox)
  182.  
  183.         call writeln(handle, 'CIDNAME=' || log.cidname)
  184.         call writeln(handle, 'CIDNUMBER=' || log.cidnumber)
  185.  
  186.         call writeln(handle, 'COMMENT=' || log.comment)
  187.  
  188.         call writeln(handle, 'FILENAME=' || log.filename)
  189.         call writeln(handle, 'ALTFILENAME=' || log.altfilename)
  190.  
  191.         call writeln(handle, 'RETURNNUMBER=' || log.returnnumber)
  192.         call writeln(handle, 'RETURNSENDFUNC=' || log.returnsendfunc)
  193.         call writeln(handle, 'RETURNSTATUS=' || log.returnstatus)
  194.  
  195.         call writeln(handle, 'RETURNRETRY=' || log.returnretry)
  196.         call writeln(handle, 'RETURNINTERVAL=' || log.returninterval)
  197.  
  198.         call close(handle)
  199.         address rexx 'broadcast' 'addtomailbox' mailbox handle
  200.     end; else call showDebugger('Could not save' logFile(mailbox, handle))
  201.  
  202.     return
  203.  
  204. /* pass a handle here */
  205. updateLogEntry: procedure expose log.
  206.     if arg() ~= 2 then do
  207.         rc = "updateLogEntry: bad args"
  208.         signal error
  209.     end
  210.     parse arg mailbox, handle
  211.  
  212.     if ~exists(mailboxDir(mailbox)) then do
  213.         call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
  214.         return
  215.     end
  216.  
  217.     if ~exists(logFile(mailbox, handle)) then do
  218.         call showDebugger('Unable to update non-existent' logFile(mailbox, handle))
  219.         return
  220.     end
  221.     opened = open(handle, logFile(mailbox, handle), 'w')
  222.  
  223.     if opened then do
  224.         call showDebugger('Updating entry' logFile(mailbox, handle))
  225.         call writeln(handle, 'TYPE=' || log.type)
  226.         call writeln(handle, 'TIME=' || log.time)
  227.         call writeln(handle, 'LENGTH=' || log.length)
  228.  
  229.         call writeln(handle, 'ORIGMAILBOX=' || log.origmailbox)
  230.  
  231.         call writeln(handle, 'CIDNAME=' || log.cidname)
  232.         call writeln(handle, 'CIDNUMBER=' || log.cidnumber)
  233.  
  234.         call writeln(handle, 'COMMENT=' || log.comment)
  235.  
  236.         call writeln(handle, 'FILENAME=' || log.filename)
  237.         call writeln(handle, 'ALTFILENAME=' || log.altfilename)
  238.  
  239.         call writeln(handle, 'RETURNNUMBER=' || log.returnnumber)
  240.         call writeln(handle, 'RETURNSENDFUNC=' || log.returnsendfunc)
  241.         call writeln(handle, 'RETURNSTATUS=' || log.returnstatus)
  242.  
  243.         call writeln(handle, 'RETURNRETRY=' || log.returnretry)
  244.         call writeln(handle, 'RETURNINTERVAL=' || log.returninterval)
  245.  
  246.         call close(handle)
  247.         address rexx 'broadcast' 'refreshmailboxentry' mailbox handle
  248.     end; else call showDebugger('Could not update' logFile(mailbox, handle))
  249.  
  250.     return
  251.  
  252.  
  253.  
  254. showDebugger: procedure
  255.     if arg() ~= 1 then do
  256.         say "showDebugger: ERROR"
  257.         exit 20
  258.     end
  259.  
  260.     parse arg debuggerInfo
  261.     
  262.     firstLine = sourceline(1)
  263.     parse var firstLine '/*' 'TITLE:' title '*/'
  264.     if showlist('p', 'AVMLOGGER') then
  265.         address 'AVMLOGGER' 'add' title ':' debuggerInfo
  266.     else
  267.         say title ':' debuggerInfo
  268.  
  269.     return 
  270.  
  271. /*-----------------------------------------------------------------------*/
  272. /*                         signal processing                             */
  273.  
  274. arexxerror:
  275. error:
  276.     call showDebugger("Error" rc "at line" sigl)
  277.     exit 20
  278.  
  279. break_c:
  280. halt:
  281.     call showDebugger("Halt/Break_C at line" sigl)
  282.     exit 20
  283.  
  284. novalue:
  285.     call showDebugger("No value at line" sigl)
  286.     exit 20
  287.  
  288. syntax:
  289.     call showDebugger("Syntax error" rc "at line" sigl)
  290.     exit 20
  291.  
  292. exit
  293.  
  294. /* this requires logfunctions.avm */
  295.  
  296. loadMailbox: procedure expose mailbox.
  297.     if arg() ~= 1 then do
  298.         rc = "loadMailbox: bad args"
  299.         signal error
  300.     end
  301.  
  302.         mailbox. = ''
  303.     parse arg mailbox
  304.  
  305.     handle = 'mailboxconfig'
  306.     opened = open(handle, mailboxDir(mailbox) || 'mailbox.cfg', 'r')
  307.     if opened then do
  308.         do while ~eof(handle)
  309.             line = readln(handle)
  310.             parse upper var line variable '=' value
  311.             mailbox.variable = value
  312.         end
  313.         call close(handle)
  314.     end
  315.     return
  316.  
  317. /* pass a handle here */
  318. saveMailbox: procedure expose mailbox.
  319.     if arg() ~= 1 then do
  320.         rc = "saveMailbox: bad args"
  321.         signal error
  322.     end
  323.     parse arg mailbox
  324.  
  325.     handle = 'mailboxconfig'
  326.     opened = open(handle, mailboxDir(mailbox) || 'mailbox.cfg', 'w')
  327.  
  328.     if opened then do
  329.         call writeln(handle, 'PASSWORD=' || mailbox.password)
  330.  
  331.         call writeln(handle, 'AUTOFAXFORWARDB=' || mailbox.autofaxforwardb)
  332.         call writeln(handle, 'AUTOFAXFORWARD=' || mailbox.autofaxforward)
  333.         call writeln(handle, 'AUTOFAXFORWARDSCRIPT=' || mailbox.autofaxforwardscript)
  334.  
  335.         call writeln(handle, 'AUTOFORWARDB=' || mailbox.autoforwardb)
  336.         call writeln(handle, 'AUTOFORWARDONDEMAND=' || mailbox.autoforwardondemand)
  337.         call writeln(handle, 'AUTOFORWARD=' || mailbox.autoforward)
  338.         call writeln(handle, 'AUTOFORWARDSCRIPT=' || mailbox.autoforwardscript)
  339.  
  340.         call writeln(handle, 'AUTOPAGEB=' || mailbox.autopageb)
  341.         call writeln(handle, 'AUTOPAGEONDEMAND=' || mailbox.autopageondemand)
  342.         call writeln(handle, 'AUTOPAGE=' || mailbox.autopage)
  343.         call writeln(handle, 'AUTOPAGESCRIPT=' || mailbox.autopagescript)
  344.  
  345.         call writeln(handle, 'AUTOALERTB=' || mailbox.autoalertb)
  346.         call writeln(handle, 'AUTOALERTONDEMAND=' || mailbox.autoalertondemand)
  347.         call writeln(handle, 'AUTOALERTSCRIPT=' || mailbox.autoalertscript)
  348.  
  349.         call close(handle)
  350.     end
  351.  
  352.     return
  353.  
  354. stdabort:
  355. exit
  356.  
  357. stdbusy:
  358. exit
  359.  
  360. stderror:
  361. exit
  362.  
  363. stdtimedout:
  364. exit
  365.  
  366. stdfaxinstruct:
  367. 'playvoice' 'avm:voices/FaxStarting'
  368. action = rc
  369. select
  370.   when action = 0 then nop
  371.   when action = 1 then do; call checkifabort; end
  372.   when action = 4 then nop
  373.   when action = 5 then nop
  374.   when action = 8 then signal stdbusy
  375.   when action = 12 then signal stdabort
  376.   when action = 14 then nop
  377.   when action = 16 then nop
  378.   otherwise signal arexxerror
  379. end
  380.  
  381. stdfax:
  382. faxscript = getclip(address() || 'FAXSCRIPT')
  383. if faxscript = '' then faxscript = 'handlefax'
  384. if symbol('mailbox') = 'VAR' then address rexx faxscript address() mailbox
  385. else address rexx faxscript address() 'anonymous'
  386. exit
  387.  
  388. stddatainstruct:
  389. 'playvoice' 'avm:voices/DataStarting'
  390. action = rc
  391. select
  392.   when action = 0 then nop
  393.   when action = 1 then do; call checkifabort; end
  394.   when action = 4 then nop
  395.   when action = 5 then nop
  396.   when action = 8 then signal stdbusy
  397.   when action = 12 then signal stdabort
  398.   when action = 14 then nop
  399.   when action = 16 then nop
  400.   otherwise signal arexxerror
  401. end
  402.  
  403. stddata:
  404. datascript = getclip(address() || 'DATASCRIPT')
  405. if datascript = '' then datascript = 'handledata'
  406. if symbol('mailbox') = 'VAR' then address rexx datascript address() mailbox
  407. else address rexx datascript address()
  408. exit
  409.  
  410. checkifabort:
  411. 'readnkeys' '1' '3'
  412. action = rc
  413. if action = 0 then value = result
  414. select
  415.   when action = 0 then do; if value = '*' then signal stdabort; end
  416.   when action = 4 then nop
  417.   when action = 5 then nop
  418.   when action = 8 then signal stdbusy
  419.   when action = 10 then nop
  420.   when action = 12 then signal stdabort
  421.   when action = 14 then signal stderror
  422.   when action = 16 then signal stderror
  423.   otherwise signal arexxerror
  424. end
  425. return
  426.  
  427.  
  428.